﻿using OpenCvSharp;

using Xc.DataAccess.CodeReader.Properties;
using Xc.DataAccess.Core;

namespace Xc.DataAccess.CodeReader.Models.Filters
{
    /// <summary>
    /// 图像混合
    /// </summary>
    [Filter("图像混合", FilterType.Algorithm)]
    public class AlgorithmAddWeight:FilterBase
    {
        /// <summary>
        /// 透明度
        /// </summary>
        [InputParameter("透明度")]
        public double Alpha1 { get; set; }
        /// <summary>
        /// 图片2
        /// </summary>
        [InputParameter("图片2")]
        public Mat Image2 { get; set; }=new Mat();
        /// <summary>
        /// 贝塔
        /// </summary>
        [InputParameter("贝塔")]
        public double Beta { get; set; }
        /// <summary>
        /// 伽马
        /// </summary>
        [InputParameter("伽马")]
        public double Gamma { get; set; }
        /// <summary>
        /// computes weighted sum of two arrays (dst = alpha*src1 + beta*src2 + gamma)
        /// </summary>
        [InputParameter("权重")]
        public int DType { get; set; } = -1;

        internal override ResultData<Mat> UseChannel(Mat mat, FilterBase[] filterInfos, FilterBase preFilterBase)
        {
            Mat mat1 = new Mat();
            Cv2.AddWeighted(mat,Alpha1,Image2, Beta, Gamma, mat1, DType);
            return ResultData<Mat>.Accept(TextResource.filter_action_complete, mat1);
        }
    }
}
